<template>
	<view class="content pc-tou-gao " >
		<view class="scroll-fix" >
			<view class="d-kuan-juzhong ">
				<!--头部-->
				<view class="d-kuan pc-dingbu ">
					<DToubu 
					@login-success="handleLoginSuccess" 
					:dengluxianshi="denglu_xianshi"
					@update-dengluxianshi="handleUpdateDengluxianshi"
					:title="quan_data.title || '选择圈子'"
					></DToubu>
				</view>

				<!--头部-->
				<!--下面内容-->
				<view class="d-kuan d-clear">
					<uv-row customStyle="margin-bottom: 10px" :gutter="10">
						<uv-col span="2" class="pc-yincang">
							
						</uv-col>
						<uv-col :span="kuan_shu">
							<!--圈子背景-->
							<view class="pc-neikuang-20-list" >
									<view class="d-kuan   d-fu-shang-10 d-yuanjiao-20-20" :style="{opacity: dataLoaded ? '1' : '0', transition: 'opacity 0.5s ease-in-out'}">
										<view class="d-fu-zuoyou-10">
											<view class="d-gao-250-1 relative d-yuanjiao-20-20" style="background-image: url('/static/img/beijing000.jpg'); background-size: cover; background-repeat: no-repeat; background-position: center;">
												<view class="d-kuan ">
													<view class="d-neikuang-10 ">

														<view class="d-fanhui-40 d-shang-10" @click="fanhui">
															<uv-icon name="arrow-left" color="#ffffff" size="18"></uv-icon>
														</view>
													</view>
												</view>
												<view class="d-kuan d-buhuanhang">
													<view class="d-kuang-100 d-shang-5 d-zuo-20 d-yuanjiao-50">
														<image :src="quan_data.tubiao" class="d-yuanjiao-50" style="width: 50px; height: 50px;" mode="aspectFill"></image>

													    
														<uv-upload
													        width="40"
													    	height="40"
													    	:fileList="fileList1"
													    	name="1"
													    	multiple
													    	leixing="1"
													    	:maxCount="1"
													    	@afterRead="afterRead"
													    	@delete="deletePic"
													    	@clickPreview="clickPreview"
													    	@insertImage="handleInsertImage"
													    	accept="image/*,video/*"
													    	:previewFullImage="true"
													    	:customStyle="{ marginLeft:'10rpx' }"
													    
													    ></uv-upload>
													    		
													
													</view>
													<view class="d-kuan d-shang-10">
														
															<uv-input placeholder="请输入圈子名称" border="surround" v-model="quan_data.title" :customStyle="{ 'background-color': 'rgba(255, 255, 255, 0.3)','color':'#ffffff !important','margin-right':'10px' }"></uv-input>
						
														<view class="d-shang-5 d-wenzi-yanse-bai-0 d-buhuanhang">
															<view class="d-shang-5"> 
																
																<uv-icon name="account" color="#ffffff" labelColor="#ffffff" size="26" :label="quan_data.name"></uv-icon> 
															</view>
															<view class="d-shang-5 d-zuo-10"> <uv-icon name="heart" color="#ffffff" labelColor="#ffffff" size="26" :label="'粉丝：'+jiaquan_shu"></uv-icon> </view>

														</view>
														<!--view class="d-kuan d-shang-5">
															
															<uv-avatar-group :urls="quan_data.touxiang" size="24" gap="0.3"></uv-avatar-group>

														</view-->
														<view class="d-shang-5 d-buhuanhang d-wenzi-yanse-bai-0"> 
															
															 <!--多文本介绍-->

														</view>
													</view>
													<view class="d-kuang-100 d-shangxia-juzhong d-you-20">
														
													</view>
												</view>
												
											</view>
										</view>
									</view>
							</view>
							<view class="pc-neikuang-20" >
								<view class="d-clear"></view>
						

								
								<!--uv-divider text="开放发布" textPosition="left"></uv-divider-->
								<!--uv-radio-group v-model="quan_data.kaifangfabu" placement="row">
									<uv-radio name="1" label="正常"></uv-radio>
									<uv-radio class="d-zuo-10" name="0" activeColor="red" label="关闭"></uv-radio>
								</uv-radio-group-->
								<!--修改开始-->
								<uv-form labelWidth="100" labelPosition="left" :model="quan_data" :rules="rules" ref="form">
									<view class="d-kuan d-wenzi-12 d-shang-10" style="color:#a6a6a6;">关闭发布后，只支持圈主发布</view>
									<uv-form-item label="开放发布" prop="kaifangfabu" borderBottom>
										<uv-radio-group v-model="quan_data.kaifangfabu" placement="row">
											<uv-radio name="1" label="正常"></uv-radio>
											<uv-radio class="d-zuo-10" name="0" activeColor="red" label="关闭"></uv-radio>
										</uv-radio-group>
									</uv-form-item>
									<view class="d-kuan d-wenzi-12 d-shang-10" style="color:#a6a6a6;">设置0元为免费进圈</view>

									<uv-form-item label="圈子价格" prop="jiage" borderBottom>
										<uv-input placeholder="请输入圈子名称" border="surround" v-model="quan_data.jiage" :customStyle="{ 'background-color': 'rgba(255, 255, 255, 0.3)','color':'#ffffff !important','margin-right':'10px' }"></uv-input>
									</uv-form-item>
									<view class="d-kuan d-wenzi-12 d-shang-10" style="color:#a6a6a6;">建议设置为365天</view>

									<uv-form-item label="有效时间" prop="huiyuan_tianshu" borderBottom>
										<uv-input placeholder="请输入有效时间（天）" border="surround" v-model="quan_data.huiyuan_tianshu" :customStyle="{ 'background-color': 'rgba(255, 255, 255, 0.3)','color':'#ffffff !important','margin-right':'10px' }"></uv-input>
									</uv-form-item>
									<uv-form-item label="圈子介绍" prop="neirong_data" borderBottom>
										<uv-textarea  v-model="quan_data.neirong_data" placeholder="请输入内容" height="50" :customStyle="{ 'background-color': 'rgba(255, 255, 255, 0.3)','color':'#ffffff !important','margin-right':'10px' }" ></uv-textarea>
									
									</uv-form-item>									
								</uv-form>





								<uv-button class="d-shang-10" @click="edit_post" shape="circle" type="default" :plain="true" text="提交修改"></uv-button>
								
								
									
							</view>
							

						</uv-col>
						<uv-col span="3" class="pc-yincang">
							
							
						</uv-col>
					</uv-row>
					

				</view>
				<!--下面内容-->


			</view>

			<view class="d-clear"></view>
		
		</view>
		

	</view>
</template>

<script>
    import Api from '@/utils/api.js';
	import QuanApi from '@/utils/quan_api.js';
	import { getRequest,postRequest } from '@/utils/wxRequest.js';
    //引入组件 d-toubu
    import DToubu from '@/components/d-toubu/d-toubu.vue'
	import Ddaohang from '@/components/d-daohang/d-daohang.vue'
	import Dweibu from '@/components/d-weibu/d-weibu.vue'
	
	
	
	export default {
		data() {
			return {
				id:'',
				title: 'Hello',
				leftNavHeight: '500rpx', // 默认高度
				
                rightColWidth: '300px', // 默认宽度
				rightColLeft: '0px', // 添加这个属性

				daohang: [
					{
						id:'1',
						name: '首页', 
						icon: 'home',

					},
					{
						id:'2',
						name: '心理学',
						icon: 'home',
						erji: [	
							{id: '2-1', name: '情绪管理'},
					    	{id: '2-2', name: '心理疗愈'},
					    	{id: '2-3', name: '行为心理学'}
						]
					},
					
				],
				erjidata:[],
				erjiindex:'',//当前激活的二级菜单索引
				activeIndex: -1, // 当前激活的一级菜单索引
				zhishi_tuijian_data:[], // 知识推荐数据
				zhishi_daohang_list:[], // 知识导航列表
				zhishi_list:[], // 知识列表
				
				imageSize: {
        		    width: 0,
        		    height: 0
        		},
				tubiaolist: 
				['integral', 'kefuv-ermai', 'coupon', 'gift', 'scan',
					'pause-circle', 'volume-off', 'email', 'list'
				],
				denglu_xianshi:0, // 登录显示

				tiezi_list:[], // 帖子列表

				currentPage: 1, //下拉加载
    			pageSize: 12, //下拉加载
    			isLoading: false, //下拉加载
    			noMoreData: false, //下拉加载
				urls: [
				],
				kuan_shu: 7, //格大小
				swiperHeight: '250',
				gao: '20', //图片高度
				tubiao_data: [
					{
						name: 'photo',
						title: '李白'
					}, {
						name: 'lock',
						title: '韩信'
					}, {
						name: 'star',
						title: '刘备'
					}, {
						name: 'star',
						title: '元芳'
					},
					{
						name: 'photo',
						title: '李白'
					}, {
						name: 'lock',
						title: '韩信'
					}, {
						name: 'star',
						title: '刘备'
					}, {
						name: 'star',
						title: '元芳'
					}

				],
				jiaquan_panduan:0, // 加圈判断
				jiaquan_shu:0, // 加圈数量
				quan_data:{}, // 圈子信息
				dataLoaded: false,
				quan_list:[
					{
					name: '最新',
					id:'1',
					},
					{
					name: '热门',
					id:'2',
					},
					{
					name: '热评',
					id:'3',
					}

				],
				shuxing:0, // 帖子排列属性 // 0等于最新，1是热门，2是热评
				shenhe_shu:0, // 审核数量
				//上传图片
				fileList1: [],//图片存储
				fabuid:{},//发布id
				uptu:[],

				







			}
		},
		components: {
  		    DToubu,
			Ddaohang,
			Dweibu
  		},
		mounted() {
			//var m = this.$store.state;
			//console.log('mmmm',m);
			
    	    this.setLeftNavHeight();
			this.getRightColWidth(); // 添加这行
    	    // 添加窗口大小变化监听
    	    window.addEventListener('resize', this.setLeftNavHeight);
			window.addEventListener('resize', this.getRightColWidth); // 添加窗口大小变化监听
			var e = this;
			//this.onImageLoad(e);
    	},
    	beforeDestroy() {
    	    // 移除监听
    	    window.removeEventListener('resize', this.setLeftNavHeight);
			window.removeEventListener('resize', this.getRightColWidth); // 添加这行
    	},
		onShow() {
			//var m = this.$store.state;
			console.log('12300000:', this.$store.state.memberuid);
			this.zhishi_daohang_api();
			var e = this;
			this.zhishi_list_api(e);
			
			this.zhishituijian_api();
			this.getTiezi_api(e,false);
			this.getJiaquan_panduan_api();//加圈判断
			this.getQuan_api();//圈子信息
			this.getShenhe_shu_api();//审核帖子数量
			this.getFabuid_api();//获取发布id

			
		},
		onLoad(e) {
			// 获取URL参数
			this.id = e.id || '';
			console.log('圈子id',this.id);
			
		},
		computed: {
		  yidenglu() {
		    return (this.$store.state.memberuid && this.$store.state.keycode) ? 1 : 0;
		  },
		  touxiang() {
		    return this.$store.state.member? this.$store.state.member.avatar : '';
		  },
		  name1() {
		    return this.$store.state.member? this.$store.state.member.name : '';
		  }
		},
		onReachBottom() {
			// 页面触底时调用methods中的加载更多方法
			this.$options.methods.onReachBottom.call(this);
		},

		methods: {
			//图片
			onImageLoad(e, index) {
				// 获取系统信息
				const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowHeight = systemInfo.windowWidth;
				if(windowHeight >=920){
					var gao = 30;
					
				} else {
					var gao = 0;

				}


				this.$nextTick(() => {
        		    
        		});

    		},
			getRightColWidth() {
				// 获取系统信息
				const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowWidth = systemInfo.windowWidth;
				var d = this;

                this.$nextTick(() => {
				if(windowWidth >=920){
					d.gao = 20;
					d.kuan_shu = 7;
					d.swiperHeight = '250';
				} else {
					d.gao = 10;
					d.kuan_shu = 12;
					d.swiperHeight = '120';

				}
				console.log('窗口高度:', windowWidth);

                 const query = uni.createSelectorQuery().in(this);
                 query.select('#youbiankuan').boundingClientRect(rect => {
                   if (rect) {
                     /*this.rightColWidth = `${rect.width+20}px`;
                     console.log('右侧列宽度:', this.rightColWidth);*/
					 	this.rightColWidth = `${rect.width-80}px`;
                    	this.rightColLeft = `${rect.left}px`; // 计算左侧位置
                    	console.log('右侧列位置:', this.rightColWidth);
                   }
                 }).exec();
               });
            },

			//首页
			shouye(){
				uni.navigateTo({
					url: '/pages/index/index',
					fail: (err) => {
						console.error('跳转失败:', err)
					}
				})
			},
			// ...其他方法保持不变...
			yiji(index) {
    		  // 切换激活的一级菜单
    		  this.activeIndex = index;
    		  // 根据激活的一级菜单显示对应的二级菜单
			  if(index == 0){
				  this.erjidata = [];
			  }else{
				  this.erjidata = this.zhishi_daohang_list[index].son;
			  }
			  const data = {
				  categories:index
			  }
			  this.zhishi_list_api(data);
    		  //this.erjidata = this.zhishi_daohang_list[index].son;
			  console.log(this.erjidata);
    		},
			erji(index) {
    		  // 切换激活的二级菜单
    		  this.erjiindex = index;

			  const data = {
				  categories:index
			  }
			  this.zhishi_list_api(data);
			  //console.log(index);

    		},
			toggleErji(index) {
    		  if (this.activeIndex === index) {
    		    // 点击已激活的菜单，收起二级菜单
    		    this.activeIndex = -1;
    		    this.currentErji = [];
    		  } else {
    		    // 点击新的菜单，显示对应的二级菜单
    		    this.activeIndex = index;
    		    this.currentErji = this.zhishi_daohang_list[index].erji;
    		  }
    		},
			setLeftNavHeight() {
        	    // 获取系统信息
        	    const systemInfo = uni.getSystemInfoSync();
        	    // 计算可用高度（可根据实际需求调整计算方式）
        	    const windowHeight = systemInfo.windowHeight;
        	    const headerHeight = 70; // 头部高度估计值
        	    const calculatedHeight = windowHeight - headerHeight;
				
        	    // 设置左边导航高度
        	    this.leftNavHeight = `${calculatedHeight}px`;
        	},
			zhishi(id){
				console.log(id);
				try {
  				  uni.navigateTo({
  				    url: '/pages/zhishi/index?id='+id,
  				    fail: (err) => {
  				      console.error('跳转失败:', err)
  				    }
  				  })
  				} catch (e) {
  				  console.error('跳转异常:', e)
  				}
			},
			
			handleLoginSuccess() {
  			  this.$forceUpdate();
  			},
			// 知识导航接口
			zhishi_daohang_api(){
				var get_data = getRequest(Api.getZhishi_daohang());
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						//var list = res.data ? res.data.data : {};
						var list = res.data && res.data.data ? res.data.data : [];
						// 在 list 前面添加插入一个新的数据“首页”
						/*list.unshift({
            			    id: '0',
							pid: '0',
            			    name: '首页',
            			    icon: 'home',
            			    son: [] // 首页没有二级菜单
            			});*/
        				this.zhishi_daohang_list = list;
						console.log(list);
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});
					}
				})
			},
			zhishi_list_api(data){
				if (!data) data = {};
				if (!data) data = {};
		  		if (!data.page) data.page = 1;
		  		if (!data.categories) data.categories = 0;
		  		if (!data.search) data.search = '';
				var get_data = getRequest(Api.getZhishi_list(data));
				var res;	
				get_data.then(duixin_data => {
					res = duixin_data;	
					if(res.data.code) {
						// 转换时间戳为日期格式
						var list = res.data? res.data.data : {};
						this.zhishi_list = list;	
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});
					}
				})
			},
			
			// 知识推荐 getZhishi_tuijian
			zhishituijian_api(){
				var get_data = getRequest(Api.getZhishi_tuijian());
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						//var list = res.data ? res.data.data : {};
						/*var list = res.data && res.data.data ? res.data.data : [];
        				this.haibao_data = list;*/
						this.zhishi_tuijian_data = res.data.data;
						
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});
					}
				})


			},
			denglu_fabu(){
				if(this.yidenglu == 0){
					this.denglu_xianshi = 1;
				} else {
					this.denglu_xianshi = 0;	
				}
				
				console.log('发布登录',this.denglu_xianshi);
				
			},
			// 更新判断是否登录
			handleUpdateDengluxianshi(value) {
			  this.denglu_xianshi = value;
			  console.log('关闭登录',this.denglu_xianshi);
			},
			// 帖子列表
			getTiezi_api(data,isLoadMore = false){
				if (!data) data = {};
				if (!data) data = {};
				if (!data.page) data.page = 1;
				//if (!data.categories) data.categories = 0;
				if (!data.search) data.search = '';
				data.categories  = this.id;
				const canshu = {
					shuxing:this.shuxing,
				}

				
				var get_data = getRequest(Api.getTiezi_list(data),canshu);
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						var list = res.data? res.data.data : {};
						if (isLoadMore) {
        				  // 加载更多时追加数据
        				  this.tiezi_list = [...this.tiezi_list, ...list];
        				} else {
        				  // 非加载更多时替换数据
        				  this.tiezi_list = list;
        				}	
						this.noMoreData = list.length < this.pageSize;

					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败，请稍后重试'
						});
					}
					this.isLoading = false;
				}).catch(() => {
    			  this.isLoading = false;
    			  if (isLoadMore) {
    			    this.currentPage--; // 加载失败时回退页码
    			  }
    			});


			},
			// 下拉加载更多
			onReachBottom() {
  			  if (this.isLoading || this.noMoreData) return;
  			  this.isLoading = true;
  			  this.currentPage++;
			  // 获取当前激活的分类ID
    			const currentCategoryId = this.activeIndex.id >= 0 ? this.activeIndex.id : 0;
    			

  			  const data = {
  			    page: this.currentPage,
  			    categories: currentCategoryId
  			  };
			  console.log('分页',this.activeIndex.id);
  			  this.getTiezi_api(data, true); // 添加第二个参数表示是加载更多
  			},
			// 帖子
			tiezi(cid,id){
				console.log(id);	
				try {
  				  uni.navigateTo({
  				    url: '/pages/tiezi/index?id='+id+'&cid='+cid,
  				    fail: (err) => {
  				      console.error('跳转失败:', err)
  				    }
  				  })
  				} catch (e) {
  				  console.error('跳转异常:', e)
  				}

			},
			// 返回
            fanhui() {
				
               // 获取页面栈
                 const pages = getCurrentPages();
                 // 如果页面栈长度小于等于1，说明没有上一级页面
                 if (pages.length <= 1) {
                    console.log('没有上一级页面');
                    uni.reLaunch({
                      url: '/pages/index/index'
                    });
                 } else {
                    // 有上一级页面则返回
                    uni.navigateBack({
                      delta: 1
                    });
                }
            },
			//加圈
			jiaquan(id){
				const uid = this.$store.state.memberuid;
                const keycode = this.$store.state.keycode;
				if (!uid || !keycode) {
    			    uni.showToast({
    			        title: '未登录',
    			        icon: 'none'
    			    });
					this.denglu_xianshi = 1;
    			    return;
    			}
				const data = {
					id: id
				}
				var post_data = postRequest(QuanApi.postJiaquan(uid,keycode),data);
				var res;
				post_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.data && res.data.data.code==1) {
						this.jiaquan_panduan = 1;
						this.jiaquan_shu = res.data.data.data;
						
						// 提示
						uni.showToast({
							icon: 'success', //有效的 icon 值为 success, loading, none
							title: '加入成功'
						});
					} else {
						this.jiaquan_panduan = 0;
						this.jiaquan_shu = res.data.data.data;
						
						// 提示
						uni.showToast({
							icon:'success', //有效的 icon 值为 success, loading, none
							title: '退出成功'

						});
					}
				})
			},
			//加圈判断
			getJiaquan_panduan_api(){
				// 确保从 获取最新值
				const uid = this.$store.state.memberuid;
                const keycode = this.$store.state.keycode;

				// id ,cid 参数
				const data = {
					id: this.id,
				}
				
				var get_data = getRequest(QuanApi.getJiaquan_panduan(uid,keycode),data);
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code && res.data.data.code > 2) {
						this.jiaquan_panduan = 0;
						this.jiaquan_shu = res.data.data.data;
					} else if(res.data.code && res.data.data.code == 1) {
						this.jiaquan_panduan = 1;
						this.jiaquan_shu = res.data.data.data;
					} else {
						this.jiaquan_panduan = 0;
						this.jiaquan_shu = res.data.data.data;
					}
				})
			},
			// 圈子信息
			getQuan_api(){
				// id ,cid 参数
				const data = {
					id: this.id,
				}
				var get_data = getRequest(QuanApi.getQuan(),data);

				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						// 转换时间戳为日期格式
						var quan_data = res.data? res.data.data[0] : [];
						this.quan_data = quan_data;
						this.dataLoaded = true;

					}
				})
			},
			fabu(id,title){
				
				getApp().globalData.currentId = id;
				getApp().globalData.title = title;

				uni.switchTab({
					url: '/pages/fabu/index',
					success: () => {
					  console.log('跳转成功');
					  
					},
					fail: (err) => {
					  console.error('跳转失败:', err);
					  uni.showToast({
							title: '跳转失败，请重试',
							icon: 'none'
					  });
					}
				});
			},
			// 帖子排列属性
			quan_click(index){
				this.activeIndex = index;
				var e = this;
				this.shuxing = index.index;
				// 0等于最新，1是热门，2是热评
				this.getTiezi_api(e,false);
			},
			//审核帖子数量
			getShenhe_shu_api(){
				const uid = this.$store.state.memberuid;
                const keycode = this.$store.state.keycode;
				const data = {
					id:this.id,
					cid:this.cid,
				}
				var get_data = getRequest(QuanApi.getShenhe_shu(uid,keycode),data);
				var res;
				get_data.then(duixin_data => {
					res = duixin_data;
					if(res.data.code) {
						
						this.shenhe_shu = res.data.data;
						
					}
				})

			},
			// 审核帖子
			shenhe(){
				uni.navigateTo({
					url: '/pages/shenhe/index?cid='+this.id,

					fail: (err) => {
					  console.error('跳转失败:', err)
					}
				  })
			},
			// 新增图片
			async afterRead(event) {
				var duixin = this; 
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
					console.log('event',event); 
					let lists = [].concat(event.file)
					let fileListLen = this[`fileList${event.name}`].length
					lists.map((item) => {
						// 判断文件类型
						const isImage = item.type.startsWith('image/');
						const isVideo = item.type.startsWith('video/');
						
						// 只处理图片和视频文件
						if (isImage || isVideo) {
							this[`fileList${event.name}`].push({
								...item,
								status: 'uploading',
								message: '上传中',
								fileType: isImage ? 'image' : 'video'
							})
						} else {
							uni.showToast({
								icon: 'none',
								title: '不支持的文件类型，请上传图片或视频'
							})
						}
					})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url,1)
					const id = duixin.uptu.data.id;
					console.log('uptu',duixin.uptu.data.id); 
					let item = this[`fileList${event.name}`][fileListLen]
					// 更新文件列表状态
						const updatedItem = Object.assign(item, {
							status: 'success',
							message: '',
							url: result,
							id: id,
							fileType: item.fileType // 保留文件类型信息
						})
						this[`fileList${event.name}`].splice(fileListLen, 1, updatedItem)
						fileListLen++
						
						// 注释掉自动插入逻辑，根据用户需求取消自动插入
						// if (updatedItem.fileType === 'image') {
						// 	this.handleInsertImage({ url: result })
						// } else if (updatedItem.fileType === 'video') {
						// 	this.handleInsertVideo({ url: result })
						// }
					}
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			//上传图片
			uploadFilePromise(url,leixing) {
				
				
				var duixin = this; 
				console.log('fabuidjiugetu',duixin.fabuid && duixin.fabuid.jiugetu); 
				const uid = this.$store.state.memberuid;
				const keycode = this.$store.state.keycode;
				// 图片上传
				var upid = duixin.fabuid && duixin.fabuid.quan_tubiao;

				
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: QuanApi.postTupians(uid,keycode)+'&fid='+upid, //
						filePath: url,
						name: 'file_data',
						formData: {
							is_ajax:1
						},
						success: (res) => {
							var duixin = this; 
							if(leixing==1){
								duixin.uptu = JSON.parse(res.data);
								//打印duixin.uptu
								console.log('duixin.uptu',duixin.uptu);
								// 假设接口返回的数据中有img_url字段包含图片URL
								// 使用正确的URL路径，并确保传递给handleInsertImage
								const imgUrl = duixin.uptu.data.url || '';
								console.log('服务器返回的图片URL:', imgUrl);
								setTimeout(() => {
									resolve(imgUrl)
								}, 1000)

							} else if(leixing==2){
								duixin.up_shipin = JSON.parse(res.data);
								//打印duixin.uptu
								console.log('duixin.up_shipin',duixin.up_shipin);
								const shipinUrl = duixin.up_shipin.data.url || '';
								console.log('服务器返回的图片URL:', shipinUrl);
								setTimeout(() => {
									resolve(shipinUrl)
								}, 1000)
							}

							

							
							// 注释掉自动插入逻辑，根据用户需求取消自动插入
						// this.handleInsertImage({url: imgUrl});
							}
					});
				})
			},
			// 关闭播放音频
			clearAllAudio() {
    		  if(this.$refs.audioPlayer) {
    		    const audioCtx = this.$refs.audioPlayer.getAudioContext();
    		    audioCtx.stop();
    		    audioCtx.destroy();
    		  }
    		},
			//发布id
			getFabuid_api(){
				var duixin = this; 
				var get_data = getRequest(Api.getFabuid());
					var res;
					get_data.then(duixin_data => {
						res = duixin_data;
						if(res.data.code) {
							duixin.fabuid = res.data.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: '获取失败，请稍后重试'
							});
						}
					})
			},
			//修改圈子
			edit_post(){
				const uid = this.$store.state.memberuid;
				const keycode = this.$store.state.keycode;
				// 上传图片
					let img = '';
					var tu =this.fileList1;
					tu.forEach(item=>{
						img+= item.id
					})
				var data = {
					id:this.id,
					title:this.quan_data.title,
					thumb:img,
					content:this.quan_data.neirong_data,
					kaifangfabu:this.quan_data.kaifangfabu,

				}


				var duixin = this; 
				var post_data = postRequest(QuanApi.postEdit_quan(uid,keycode,this.id),data);
					var res;
					post_data.then(duixin_data => {
						res = duixin_data;
						if(res.data.code) {
							uni.showToast({
								icon: 'none',
								title: '修改成功'
							});
							this.getQuan_api();
						} else {
							uni.showToast({
								icon: 'none',
								title: '修改失败，请稍后重试'
							});
						}
					})
			}

			







		}
	}
</script>

<style>

	.content {
		
		
		display: flex;
		flex-direction: column;
		align-items: center;
		
		background-color: #f3f3f3;
		
		margin-bottom: 70px;
		
		box-sizing: border-box;
		overflow-x: hidden;
		

	}
	.d-gao-250-1{
		height: 450rpx;

	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	/* 屏幕宽度大于786px时隐藏uni-page-head */
    @media (min-width: 786px) {
        uni-page-head {
            display: none !important;
            opacity: 0 !important;
            height: 0 !important;
            visibility: hidden !important;
        }
    }
	/*.d-daohang{
		
		width: 600rpx;
	}*/
	/* 添加在style部分 */
	.d-daohang-zuo {
    position: fixed;
    left: 0;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #f5f5f5;
    z-index: 100;
	box-shadow: 2px 0 5px rgba(177, 177, 177, 0.1);
  }
  
  .d-daohang-you {
    position: fixed;
    left: 180rpx;
    
    width: 180rpx;
    height: calc(100vh - 70rpx);
    background: #fff;
    z-index: 100;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  }
   
   
   
   
   
   
   
   
   
 
   
  .d-erji-item {
    height: 60rpx;
    line-height: 60rpx;
    padding: 0 20rpx;
   /* border-bottom: 1px solid #f0f0f0;*/
  }
  
  .d-erji-item:active {
    background: #f5f5f5;
  }
  .you-guding {
	position: fixed;
	top: 0; /* 根据头部高度调整 */
	/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
	transition: all 0.3s ease;
}
/* 大于786px时的样式 */
@media screen and (min-width: 1024px) {
	.d-bianhua-10 {
		padding: 30px;
	}
	.pc-zuo-520 {
		margin-left: 520rpx;
		
	}
	.you-guding {
		position: fixed;
			
		top: 60px; /* 根据头部高度调整 */
		/*box-shadow: -2px 0 5px rgba(0,0,0,0.1);*/
		transition: all 0.3s ease;
	}
		
	
}
	
</style>
